旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � Programming the SoundBlaster Pro � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 Written for the PC-GPE by Mark Feldman e-mail address : u914097@student.canberra.edu.au myndale@cairo.anu.edu.au 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � THIS FILE MAY NOT BE DISTRIBUTED � � SEPARATE TO THE ENTIRE PC-GPE COLLECTION. � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� 旼컴컴컴컴컴컫컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � Disclaimer � 읕컴컴컴컴컴켸 I assume no responsibility whatsoever for any effect that this file, the information contained therein or the use thereof has on you, your sanity, computer, spouse, children, pets or anything else related to you or your existance. No warranty is provided nor implied with this information. 旼컴컴컴컴컴컴컫컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � Introduction � 읕컴컴컴컴컴컴켸 I still own a SoundBlaster 1.0 (don't laugh) so I haven't been able to test any of the information in this file, ie don't take any of this as fact. 旼컴컴컴컴컴컴컫컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � Stereo Sound � 읕컴컴컴컴컴컴켸 Generating stereo FM sound on the SB Pro is similar to the way it's done on the SB 1.x, you just use different ports for the left and right channels. The file ADLIB.TXT has more information on this. Generating stereo sounds with the DSP is similar to the mono method, but you send *two* bytes for every sample. The first one goes to the left channel and the second one goes to the right. You also need to reset the mixer chip and tell the soundblaster you want to play a stereo sound (see below). This has the advantage in that you can store the info for both channels in a single data block and transfer it by still using only one DMA channel. The WAV file format actually stores it's audio waveform data like this (see the PC-GPE file WAV.TXT). Left channel bytes 0 1 2 3 4 5 6 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴 � � � � � � � � � � � � � � � ........ 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴 0 1 2 3 4 5 6 Right channel bytes To play the sound the SoundBlaster Pro is set for stereo output and the DMA chip is programmed to send this chunk as is. 旼컴컴컴컴컴컴컴컴컴컴컴컫컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � The CT 1345 Mixer Chip � 읕컴컴컴컴컴컴컴컴컴컴컴켸 You access the mixer registers the same way you access the regular SB registers, but Port 2x4h is the index port and 2x5h is the data read/write port, where x = 2 for base address jumper setting 220h x = 3 for base address jumper setting 230h x = 4 for base address jumper setting 240h So setting a mixer register to a given value can be accomplished with the following procedure: { base = 220h, 230 or 240h } procedure SetMixerReg(base : word; index, value : byte); begin Port[base + 4] := index; Port[base + 5] := value; end; You can also read a register's current value: function GetMixerReg(base : word; index : byte) : byte; begin Port[base + 4] := index; GetMixerReg := Port[base + 5]; end; The Data Reset register is used to reset the mixer chip. Set this register to 0 before changing any of the other mixer registers. Index = 00h 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴컴컴컴컴쩡컴컴컴컴컴컴� � Data Reset The Input register selects the SB Pro sound input source and filter type. Index = 0Ch 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴쩡컴� 읕쩡� � � 旼컴컴컴컴컴좔컴컴� 旼좔컴컴컴컴컴컴컴컴� � In Filter � � ADC Source � � 000 - Low � � 00 - Microphone 1 � � 001 - High � � 01 - CD � � 010 - No Filter � � 10 - Microphone 2 � 읕컴컴컴컴컴컴컴컴� � 11 - Line In � 읕컴컴컴컴컴컴컴컴컴� The Output register determines whether to output sound in stereo or mono, in stereo two bytes must be sent for each sample, the first one goes to the left channel and the next one goes to the right. This register allows you to bypass the output filter. Index = 0Eh 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� � � 旼컴컴컴컴컴컨컴컴컴컴컴� 旼컨컴컴컴컴커 � DNFI � � VSTC � � 0 - Use O/P Filter � � 0 - Mono � � 1 - Bypass O/P Filter � � 1 - Stereo � 읕컴컴컴컴컴컴컴컴컴컴컴� 읕컴컴컴컴컴켸 The Master Volume register allows you to set the master volume of each channel: Index = 22h 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴쩡컴컴� 읕컴컴쩡컴컴� � � 旼컴컴컴컨컴컴컴왯컴컴컴컨컴컴컴커 � Master Volume 납 Master Volume � � Left 납 Right � 읕컴컴컴컴컴컴컴牡컴컴컴컴컴컴컴켸 The Voice Volume register allows you to set the volume of each channel for DSP output: Index = 04h 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴쩡컴컴� 읕컴컴쩡컴컴� � � 旼컴컴컴좔컴컴커旼컴컴컴좔컴컴커 � Voice Volume 납 Voice Volume � � Left 납 Right � 읕컴컴컴컴컴컴켸읕컴컴컴컴컴컴켸 Voice Volume Voice Volume Left Right The FM Volume register allows you to set the volume of each channel for FM wave synthesis: Index = 26h 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴쩡컴컴� 읕컴컴쩡컴컴� � � 旼컴컴좔컴컴� 旼컴컴좔컴컴� � FM Volume � � FM Volume � � Left � � Right � 읕컴컴컴컴컴� 읕컴컴컴컴컴� The CD Volume register allows you to set the volume of each channel for CD output: Index = 28h 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴쩡컴컴� 읕컴컴쩡컴컴� � � 旼컴컴좔컴컴� 旼컴컴좔컴컴� � CD Volume � � CD Volume � � Left � � Right � 읕컴컴컴컴컴� 읕컴컴컴컴컴� The Line Volume register allows you to set the volume of each channel for line in channel: Index = 2Eh 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴컴쩡컴컴� 읕컴컴쩡컴컴� � � 旼컴컴컨컴컴컴� 旼컴컴컨컴컴컴� � Line Volume � � Line Volume � � Left � � Right � 읕컴컴컴컴컴컴� 읕컴컴컴컴컴컴� The Mic Mixing register allows you to set the input volume for the microphone: Index = 0Ah 旼컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴쩡컴� � 7 � 6 � 5 � 4 � 3 � 2 � 1 � 0 � 읕컴좔컴좔컴좔컴좔컴좔컴좔컴좔컴� 읕컴쩡컴� � 旼컴컴컨컴컴커 � Mic Mixing � 읕컴컴컴컴컴켸 旼컴컴컴컴컴컫컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴� � References � 읕컴컴컴컴컴켸 Title : The SoundBlaster Developpers Kit Publishers : Creative Labs Inc Creative Technology PTE LTD Title : Sound Blaster - The Official Book Authors : Richard Heimlich, David M. Golden, Ivan Luk, Peter M. Ridge Publishers : Osborne/McGraw Hill ISBN : 0-07-881907-5 Some of the information in this file was either obtained from or verified by the source code in a public domain library called SOUNDX by Peter Sprenger. I haven't tried using his library yet (I don't have a C compiler at the moment) but it looks very well done and contains numerous sound card detection routines. Says Peter : "It would be nice, that when you make something commercial with my routines, that you send me a copy of your project or send me some bucks, just enough for pizza and coke to support my night programming sessions. If you send me nothing, ok. But USE the stuff, if you can need it!". Heh...a REAL programmer! ftp site: ftp.uwp.edu directory: /pub/msdos/demos/programming/game-dev/source filename: soundx.zip